<?php
header("content-type:text/html;charset=utf-8");
session_start();
include "public/is_login.php";
include "../public/config/config.php";
include "../public/include/funcs.php";

$id = $_GET['id'] ? $_GET['id'] : $_SESSION['id'];
if(!$id) $id = $did;
if(!$id) $id = 1;

$link=conn($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd,$cfg_dbname,$cfg_dbchar);

$arr = select($link, "user", "id=$id");
$name = $arr[0]['tname'] ? $arr[0]['tname'] : $arr[0]['nickname'];
$u_img = $arr[0]['u_img'];
$pid = $arr[0]['pid'];
$menber = $arr[0]['menber'];
$juewei = $arr[0]['juewei'];
if($pid == 0){
	$puser = "您是顶级会员";
}else{
	$parr = select($link, "user", "id=$pid");
	$pname = $parr[0]['tname'] ? $parr[0]['tname'] : $parr[0]['nickname'];
	$puser = $pname."，ID：".$pid."";
}

$row_arr = select($link, "hidden","u_id=$id");
$dis = ['','style="display: none;"'];

if($row_arr[0]['row8'] == '1'){
	$row8 = '';
}else{
	$row8 = 'style="display: none;"';
}


function find_id($link,$id){
	global $arr_all;
	$arr=select($link, "user","pid=$id");
	foreach($arr as $v){
		$arr_all[]=$v;
		find_id($link,$v['id']);
	}
}
$arr_all = array();
$arr_all[]=$arr[0];
find_id($link, $id);
$team = count($arr_all);


mysqli_close($link);
//echo "<pre>";
//print_r($arr_all);
//print_r($parr);
//print_r($row_arr);
//echo "</pre>";
?>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
	<title>分享商城 -- 个人中心</title>
	
	<!-- Bootstrap -->
	<link href="/public/css/bootstrap.min.css" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="public/main.css"/>
	
	<!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
	<!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
	<!--[if lt IE 9]>
	<script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
	<script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
	<![endif]-->
</head>
<body class="bg_lit">

<!--<div class="container">
	<img class="list-logo" src="imgs/list/logo.png"/>
</div>-->

<div class="head_top">
	<div class="u_img">
		<img class="img-rounded" src="<?php echo $u_img;?>"/>
	</div>
	<div class="u_name">
		<p class="u_title"><?php echo $name;?></p>
		<p class="u_id">ID号：<?php echo $id;?></p>
	</div>
	<div class="clear"></div>
</div>

<div class="container">
	<a <?php echo $dis[$row_arr[0]['row1']];?> href="pv.php?id=<?php echo $id;?>">
		<div class="pay_u">
			<span class="col-md-12">
				<span class="glyphicon glyphicon-piggy-bank uspan_1" aria-hidden="true"></span>
				<span class="uspan_2">&nbsp; PV值</span>
				<span class="uspan_22">（<span id="pv">0</span> 元）</span>
				<span class="glyphicon glyphicon-menu-right uspan_3 pull-right" aria-hidden="true"></span>
			</span>
		</div>
		<div class="h10"></div>
	</a>
	
	
	<a <?php echo $dis[$row_arr[0]['row']];?> href="my_goods.php?id=<?php echo $id;?>">
		<div class="pay_u2">
			<span class="col-md-12">
				<span class="glyphicon glyphicon-check uspan_1" aria-hidden="true"></span>
				<span class="uspan_2">&nbsp; 我的商品</span>
				
				<span class="glyphicon glyphicon-menu-right uspan_3 pull-right" aria-hidden="true"></span>
			</span>
		</div>
		<div class="bder"></div>
	</a>
	
	<a <?php echo $dis[$row_arr[0]['row2']];?> href="myshare.php?id=<?php echo $pid;?>">
		<div class="pay_u2">
			<span class="col-md-12">
				<span class="glyphicon glyphicon-upload uspan_1" aria-hidden="true"></span>
				<span class="uspan_2">&nbsp; 我的推荐人</span>
				<span class="uspan_22">（<?php echo $puser;?>）</span>
				<span class="glyphicon glyphicon-menu-right uspan_3 pull-right" aria-hidden="true"></span>
			</span>
		</div>
		<div class="bder"></div>
	</a>
	
	<a <?php echo $dis[$row_arr[0]['row3']];?> href="../vkdsm/see_user_tree.php?id=<?php echo $id;?>">
		<div class="pay_u2">
			<span class="col-md-12">
				<span class="glyphicon glyphicon-equalizer uspan_1" aria-hidden="true"></span>
				<span class="uspan_2">&nbsp; 我的团队</span>
				<span class="uspan_22">（<?php echo $team;?> 人）</span>
				<span class="glyphicon glyphicon-menu-right uspan_3 pull-right" aria-hidden="true"></span>
			</span>
		</div>
		<div class="bder"></div>
	</a>
	
	<a <?php echo $dis[$row_arr[0]['row4']];?> href="my_menber.php?id=<?php echo $id;?>">
		<div class="pay_u2">
			<span class="col-md-12">
				<span class="glyphicon glyphicon-tower uspan_1" aria-hidden="true"></span>
				<span class="uspan_2">&nbsp; 我的会员级别</span>
				<span class="uspan_22">（<?php echo $menber;?>）</span>
				<span class="glyphicon glyphicon-menu-right uspan_3 pull-right" aria-hidden="true"></span>
			</span>
		</div>
		<div class="bder"></div>
	</a>
	
	<a <?php echo $dis[$row_arr[0]['row5']];?> href="my_juewei.php?id=<?php echo $id;?>">
		<div class="pay_u2">
			<span class="col-md-12">
				<span class="glyphicon glyphicon-knight uspan_1" aria-hidden="true"></span>
				<span class="uspan_2">&nbsp; 我的爵位级别</span>
				<span class="uspan_22">（<?php echo $juewei;?>）</span>
				<span class="glyphicon glyphicon-menu-right uspan_3 pull-right" aria-hidden="true"></span>
			</span>
		</div>
		<div class="bder"></div>
	</a>
	
	<a <?php echo $dis[$row_arr[0]['row6']];?> href="huodong.php">
		<div class="pay_u2">
			<span class="col-md-12">
				<span class="glyphicon glyphicon-bullhorn uspan_1" aria-hidden="true"></span>
				<span class="uspan_2">&nbsp; 活动中心</span>
				<span class="glyphicon glyphicon-menu-right uspan_3 pull-right" aria-hidden="true"></span>
			</span>
		</div>
		<div class="bder"></div>
	</a>
	
	<a <?php echo $dis[$row_arr[0]['row7']];?> href="share.php?id=<?php echo $id;?>">
		<div class="pay_u2">
			<span class="col-md-12">
				<span class="glyphicon glyphicon-new-window uspan_1" aria-hidden="true"></span>
				<span class="uspan_2">&nbsp; 分享给好友</span>
				<!--<span class="uspan_22">（让好友识别我的二维码）</span>-->
				<span class="glyphicon glyphicon-menu-right uspan_3 pull-right" aria-hidden="true"></span>
			</span>
		</div>
		<div class="bder"></div>
	</a>
	
	<a <?php echo $row8;?> href="share2.php?id=<?php echo $id;?>">
		<div class="pay_u2">
			<span class="col-md-12">
				<span class="glyphicon glyphicon-new-window uspan_1" aria-hidden="true"></span>
				<span class="uspan_2">&nbsp; 分享给商家</span>
				<!--<span class="uspan_22">（---）</span>-->
				<span class="glyphicon glyphicon-menu-right uspan_3 pull-right" aria-hidden="true"></span>
			</span>
		</div>
		<div class="bder"></div>
	</a>
	
	<a href="save.php">
		<div class="h10"></div>
		<div class="pay_u">
			<span class="col-md-12">
				<span class="glyphicon glyphicon-cog uspan_1" aria-hidden="true"></span>
				<span class="uspan_2">&nbsp; 设置</span>
				<!--<span class="uspan_22">（完善个人信息）</span>-->
				<span class="glyphicon glyphicon-menu-right uspan_3 pull-right" aria-hidden="true"></span>
			</span>
		</div>
	</a>
	
</div>


<?php include "template/footer.php";?>

<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script type="text/javascript" src="/public/js/jquery-3.3.1.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script type="text/javascript" src="/public/js/bootstrap.min.js"></script>
<script type="text/javascript">
function msg(){
	alert("该功能正在发开中...");
}

var ajax = new XMLHttpRequest();
ajax.open('get','ajax/get_pv.php?id='+<?php echo $id;?>);
ajax.send();
ajax.onreadystatechange = function () {
	if (ajax.readyState==4 &&ajax.status==200) {
		var num = ajax.responseText;
		pv.innerHTML = num;
//		console.log(num);
	}
}


</script>
</body>
</html>